#! /usr/bin/env python
# -*- coding:utf-8 -*-
# ====#====#====#====

import requests

# 将接口调用进行判断，根据不同的调用方式

# 定义接口调用类
class ConfigHttp(object):
    # 定义初始化函数
    def __init__(self, m, u, v, h):
        self.method = m
        self.url = u
        self.value = v
        self.header = h

    # 定义请求的私有函数
    def __get(self):
        re = requests.get(url=self.url, params=self.value, headers=self.header)
        return re

    def __post(self):
        re = requests.post(url=self.url, data=self.value, headers=self.header)
        return re

    # 定义对外调用方法
    def get_method(self):
        if self.method == 'get':
            re = self.__get()
            return re
        elif self.method == 'post':
            re = self.__post()
            return re


if __name__ == '__main__':
    re = ConfigHttp('post', 'https://www.wanandroid.com/user/login', "{'username':'liangchao','password':'123456'}", '')
    a = re.get_method()
    print(a.text)